# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Daniel Nagy <danielnagy at gmx de>
# Contributor: hauzer <hauzer@gmx.com>

_hkgname=cookie
pkgname=haskell-cookie
pkgver=0.4.6
pkgrel=1
pkgdesc="HTTP cookie parsing and rendering"
url="https://hackage.haskell.org/package/${_hkgname}"
license=('MIT')
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-data-default-class')
makedepends=('ghc')
source=(https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)
sha512sums=('8ba83a26940c8ff21a9a881e3ecc9947221dfcbfc31bd33a5d1c28f8256bd1260d16672d55bb91eadd1eafbe930195108c6ab8b6fe924f05f979c77a2ec0fba6')

build() {
    cd $_hkgname-$pkgver
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid -fnetwork-uri
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register   --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver

    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
